package com.atguigu.spzx.manager.controller;

import com.atguigu.spyx.model.common.Result;
import com.atguigu.spzx.manager.service.SysRoleMenuService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author LT
 * @create 2023-11-07-11:16
 */
@RestController
@RequestMapping("/admin/system/roleMenu")
public class SysRoleMenuController {

    @Resource
    SysRoleMenuService sysRoleMenuService;

    @GetMapping("findMenusByRoleId/{roleId}")
    public Result findMenusByRoleId(@PathVariable("roleId") Long roleId){
        Map<String,Object> map = sysRoleMenuService.findMenusByRoleId(roleId);
        return Result.ok().data(map);
    }
    @PutMapping ("/assignMenus2Role/{roleId}")
    public Result assignMenus2Role(@PathVariable("roleId") Long roleId,
                                    @RequestBody List<Long> menuIds){
        sysRoleMenuService.assignMenus2Role(roleId,menuIds);
        return Result.ok();
    }
}
